package com.yx.vectordb.api;

import com.yx.vectordb.impl.VectorSearchResult;
import com.yx.vectordb.impl.YxVectorDB;

import java.io.File;
import java.util.Collection;
import java.util.List;

/**
 * 向量存储接口
 * 定义向量数据库的基本操作
 */
public interface IVectorDB<T extends IMetaData> extends AutoCloseable {

    public String addVector(String id, float[] vector, T meta) throws Exception;

    /**
     * 删除向量
     * @param id 向量ID
     */
    void deleteVector(String id) throws Exception;

    void deleteVector(Collection<String> ids) throws Exception;

    void deleteBy(String whereCondition) throws Exception;

    List<VectorSearchResult<T>> search(float[] queryVector, int k, String whereCondition) throws Exception;

    List<VectorSearchResult<T>> search(float[] queryVector, float threshold, String whereCondition) throws Exception;

    List<VectorSearchResult<T>> search(float[] queryVector, float threshold, int k, String whereCondition) throws Exception;

    public void close() throws Exception;

    public  static <T extends IMetaData> IVectorDB<T> open(File dbDirectory, Class<T> metaInfoBeanClass, int dimension) throws Exception {
        YxVectorDB<T> db = new YxVectorDB<>();
        db.open(dbDirectory, metaInfoBeanClass, dimension);
        return db;
    }

}